package com.fzf.org.service.impl;

import com.fzf.org.mq.producer.BlogReviewerProducer;
import com.fzf.org.service.BlogAuditService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.stream.RecordId;
import org.springframework.stereotype.Service;

/**
 * 博客审核服务实现类
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class BlogAuditServiceImpl implements BlogAuditService {

    private final BlogReviewerProducer blogReviewerProducer;

    /**
     * 发送博客审核请求（使用消息队列异步处理）
     *
     * @param blogId 博客ID
     */
    @Override
    public boolean sendBlogAuditRequest(Long blogId) {
        if (blogId == null) {
            log.error("Invalid audit request parameters: blogId={}, action={}", blogId);
            return false;
        }
        RecordId recordId = blogReviewerProducer.sendBlogReviewMessage(blogId);
        log.info("Blog audit request sent to message queue, blogId: {}, recordId: {}", blogId, recordId);
        return true;
    }
}